package com.alstudio.net.protocol.xmpp.parser;

import java.io.IOException;

import com.alstudio.net.callback.XmppEventListener;
import com.alstudio.net.protocol.xmpp.XmlReader;

public class BaseParser {
	
	protected XmlReader mReader;
	
	protected String stream;
	
	protected XmppEventListener mListener;


	protected String parseText(XmlReader reader) throws IOException {
		final String endTagName = reader.getName();
		final StringBuffer str = new StringBuffer("");
		int t = reader.next(); // omit start tag
		while (!endTagName.equals(reader.getName())) {
			if (t == XmlReader.TEXT) {
				str.append(reader.getText());
			}
			t = reader.next();
		}
		return str.toString();
	}

	protected void parseIgnore(XmlReader reader) throws IOException {
		int x;
		while ((x = reader.next()) != XmlReader.END_TAG) {
			if (x == XmlReader.START_TAG) {
				this.parseIgnore(reader);
			}
		}
	}

	
}
